package com.drug.mingkang.controller;

import com.drug.mingkang.model.AuditRecord;
import com.drug.mingkang.model.HqReview;
import com.drug.mingkang.model.vo.AuditRecordVo;
import com.drug.mingkang.model.vo.PurchasereviewVo;
import com.drug.mingkang.service.HqReviewService;
import com.drug.mingkang.utils.Tools;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (HqReview)表控制层
 *
 * @author wenchangjian
 * @since 2020-08-11 12:00:13
 */
@RestController
@RequestMapping("hqReview")
public class HqReviewController {
    /**
     * 服务对象
     */
    @Resource
    private HqReviewService hqReviewService;

    @Resource
    private Tools tools;
    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public HqReview selectOne(String id) {
        return this.hqReviewService.queryById(id);
    }

    /**
     * 原材料审核表
     * @author 依旧
     * @return 列表
     */
    @PostMapping("rawMaterialShowAll")
    public Map<String,Object> rawMaterialShowAll(PurchasereviewVo purchasereviewVo){
        List<HqReview> list = hqReviewService.queryAllByLimit(purchasereviewVo);
        int count=hqReviewService.selectCount(purchasereviewVo);
        return tools.limit(list,count);
    }


    /**
     * 根据业务ID查询审核记录
     * @param auditRecordVo
     * @return
     */
    @PostMapping("findBybusinessId")
    public Map<String,Object> findBybusinessId(AuditRecordVo auditRecordVo){

        List<AuditRecord> list = hqReviewService.findBybusinessId(auditRecordVo);
        int count = hqReviewService.fcount(auditRecordVo);
        Map<String,Object> map = tools.limit(list,count);
        return map;
    }
}